package com.situ.stmall.user.mapper;

import com.situ.stmall.user.entity.OrderDetails;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

public interface OrderDetailsMapper {
    @Delete({
        "delete from order_details",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into order_details (id, goods_id, ",
        "order_id, price, ",
        "count)",
        "values (#{id,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, ",
        "#{orderId,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, ",
        "#{count,jdbcType=INTEGER})"
    })
    int insert(OrderDetails row);

    @Select({
        "select",
        "id, goods_id, order_id, price, count",
        "from order_details",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.INTEGER),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.VARCHAR),
        @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
        @Result(column="count", property="count", jdbcType=JdbcType.INTEGER)
    })
    OrderDetails selectByPrimaryKey(Integer id);

    @Select({
        "select",
        "id, goods_id, order_id, price, count",
        "from order_details"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.INTEGER),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.VARCHAR),
        @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL),
        @Result(column="count", property="count", jdbcType=JdbcType.INTEGER)
    })
    List<OrderDetails> selectAll();

    @Update({
        "update order_details",
        "set goods_id = #{goodsId,jdbcType=INTEGER},",
          "order_id = #{orderId,jdbcType=VARCHAR},",
          "price = #{price,jdbcType=DECIMAL},",
          "count = #{count,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(OrderDetails row);
}